package miracle.joker.design.facade;

import java.util.List;

public class CartFacade {
    private Cart cart = new Cart();

    public void addItem(String name, double price) {
        Item item = new Item(name, price);
        cart.addItem(item);
        System.out.println("Item " + name + " added to the cart.");
    }

    public void removeItem(String name) {
        List<Item> items = cart.getItems();
        for (int i = 0; i < items.size(); i++) {
            Item item = items.get(i);
            if (item.getName().equals(name)) {
                cart.removeItem(item);
                System.out.println("Item " + name + " removed from the cart.");
                break;
            }
        }
    }

    public double getTotalPrice() {
        double total = cart.getTotalPrice();
        System.out.println("Cart totalprice is: " + total);
        return total;
    }
}
